package com.einmeer.hfbank.service.impl;

import com.einmeer.hfbank.entity.Bank;
import com.einmeer.hfbank.hfconst.BankConst;
import com.einmeer.hfbank.mapper.BankMapper;
import com.einmeer.hfbank.service.BankService;
import com.einmeer.hfbank.vo.ResultVo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 芊嵛
 * @date 2024/1/12
 */
@Service
public class BankServiceImpl implements BankService {
    @Resource
    private BankMapper bankMapper;

    /**
     * 根据bankId查询银行详细信息
     * @param bankId
     * @return
     */
    @Override
    public ResultVo queryBankInfo(Integer bankId) {
        Bank bank = bankMapper.selectBankInfo(bankId);
        if (bank==null){
            return new ResultVo(BankConst.BankNO,BankConst.QUERYNO);
        }
        return new ResultVo(BankConst.BankOK,bank,BankConst.QUERYOK);
    }

    /**
     * 查询银行bankId、bankName
     * @return
     */
    @Override
    public ResultVo queryAllBanks() {
        List<Bank> list = bankMapper.selectAllBanks();
        if (list.isEmpty()){
            return new ResultVo(BankConst.BankNO,BankConst.QUERYNO);
        }
        return new ResultVo(BankConst.BankOK,list,BankConst.QUERYOK);
    }
}
